﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using TestStack.White;
using TestStack.White.Factory;
using TestStack.White.UIItems;
using TestStack.White.UIItems.Finders;
using TestStack.White.UIItems.ListBoxItems;
using TestStack.White.UIItems.WindowItems;

namespace White_SimpleExample_ConsoleApp
{
    class Program 
    {
        Application app = null;
        static System.Diagnostics.Process process = null;
        static void Main(string[] args)
        {
            string path = Directory.GetCurrentDirectory() + "\\WFApp.exe";

            process = System.Diagnostics.Process.Start(path);

            Application app = TestStack.White.Application.Attach(process);
            Window wform = app.GetWindow("Form1", InitializeOption.NoCache);

            TextBox txtNum = wform.Get<TextBox>(SearchCriteria.ByAutomationId("txtNum"));
            txtNum.Text = "30";

            TextBox txtNum2 = wform.Get<TextBox>(SearchCriteria.ByAutomationId("txtNum2"));
            txtNum2.Text = "50";

            ComboBox cboFuHao = wform.Get<WinFormComboBox>(SearchCriteria.ByAutomationId("cboFuHao"));
            cboFuHao.Select(2);

            Button btnJs = wform.Get<Button>(SearchCriteria.ByAutomationId("btnJs"));
            btnJs.Click();

            Console.WriteLine("按任意键结束....");
            Console.ReadKey();
            if (process != null)
            {
                process.Kill();
            }
        }
    }
}
